<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%request.setCharacterEncoding("utf-8");%> 
<%@ page contentType="text/html;charset=utf-8"%>  
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>省-市-学校三级级联菜单</title>
    <script type="text/javascript" src="<%=path%>/commonjs/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="<%=path%>/commonjs/jquery-1.7.1.js"></script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
  <s:form action="login">
    
           三级级联菜单<br><br>
    省份:
    <select id="common_jilian_province">
    	<option value="">请选择省份</option>
    </select><br>
    城市:
    <select id="common_jilian_city" style="display: none;">
    	<option value="">请选择城市</option>
    </select><br>
     学校:
    <select id="common_jilian_school" style="display: none;">
    	<option value="">请选择学校</option>
    </select><br>
    <s:submit value="提交"></s:submit>
    </s:form>
	<script type="text/javascript">
		$.post("<%=basePath%>json/acquireAllProvince.action",{},function(data){
			for(var i=0;i<data.list.length;i++){
				$('<option value="'+data.list[i].id+'">'+data.list[i].name+'</option>').appendTo($('#common_jilian_province'));
			}
		},
		"json");
		function click_aa(){
			alert($("#common_jilian_province").val());
		}
		$("#common_jilian_province").change(function(){
			var this_value=$(this).val();
			if(this_value){
				$("#common_jilian_city").show();
				$("#common_jilian_school").hide();
				$("#common_jilian_city").html('');
				$("#common_jilian_school").html('');
				$('<option value="">请选择城市</option>').appendTo($('#common_jilian_city'));
				$.post("<%=basePath%>json/acquirtCityByProvinceId.action",
				{provinceId:this_value},
				function(data){
					if(data.list.length>0){
						for(var i=0;i<data.list.length;i++){
							$('<option value="'+data.list[i].id+'">'+data.list[i].name+'</option>').appendTo($('#common_jilian_city'));
						}
					}else{
						alert("本省中暂无城市信息");
					}
				},
				"json");
				
			}else{
				$("#common_jilian_city").hide();
				$("#common_jilian_school").hide();
				$("#common_jilian_city").html('');
				$("#common_jilian_school").html('');
			}
		});
		$("#common_jilian_city").change(function(){
			var this_value=$(this).val();
			if(this_value){
				$("#common_jilian_school").show();
				$("#common_jilian_school").html('');
				$('<option value="">请选择学校</option>').appendTo($('#common_jilian_school'));
				$.post("<%=basePath%>json/acquireSchoolByCityId.action",
					{cityId:this_value},
					function(data){
						if(data.list.length>0){
							for(var i=0;i<data.list.length;i++){
								$('<option value="'+data.list[i].id+'">'+data.list[i].name+'</option>').appendTo($('#common_jilian_school'));
							}
						}else{
							alert("本市中暂无学校信息");
						}
					},
					"json"
				);
				
			}else{
				$("#common_jilian_school").hide();
				$("#common_jilian_school").html('');
			}
		});
	</script>
    
  </body>
</html>
